<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>ib_insync.order &mdash; ib_insync 0.9.70 documentation</title>
      <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
      <link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
    <link rel="canonical" href="https://ib_insync.readthedocs.io_modules/ib_insync/order.html"/>
  
        <script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/underscore.js"></script>
        <script src="../../_static/doctools.js"></script>
    <script src="../../_static/js/theme.js"></script>
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" /> 
</head>

<body class="wy-body-for-nav"> 
  <div class="wy-grid-for-nav">
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
            <a href="../../index.html" class="icon icon-home"> ib_insync
          </a>
              <div class="version">
                0.9
              </div>
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>
        </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
              <ul>
<li class="toctree-l1"><a class="reference internal" href="../../readme.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api.html">API docs</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../notebooks.html">Notebooks</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../recipes.html">Code recipes</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../code.html">Source code</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../changelog.html">Changelog</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../links.html">Links</a></li>
</ul>

        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../index.html">ib_insync</a>
      </nav>

      <div class="wy-nav-content">
        <div class="rst-content">
          <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../../index.html" class="icon icon-home"></a> &raquo;</li>
          <li><a href="../index.html">Module code</a> &raquo;</li>
      <li>ib_insync.order</li>
      <li class="wy-breadcrumbs-aside">
      </li>
  </ul>
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
             
  <h1>Source code for ib_insync.order</h1><div class="highlight"><pre>
<span></span><span class="sd">&quot;&quot;&quot;Order types used by Interactive Brokers.&quot;&quot;&quot;</span>

<span class="kn">from</span> <span class="nn">dataclasses</span> <span class="kn">import</span> <span class="n">dataclass</span><span class="p">,</span> <span class="n">field</span>
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">ClassVar</span><span class="p">,</span> <span class="n">List</span><span class="p">,</span> <span class="n">NamedTuple</span><span class="p">,</span> <span class="n">Set</span>

<span class="kn">from</span> <span class="nn">eventkit</span> <span class="kn">import</span> <span class="n">Event</span>

<span class="kn">from</span> <span class="nn">.contract</span> <span class="kn">import</span> <span class="n">Contract</span><span class="p">,</span> <span class="n">TagValue</span>
<span class="kn">from</span> <span class="nn">.objects</span> <span class="kn">import</span> <span class="n">Fill</span><span class="p">,</span> <span class="n">SoftDollarTier</span><span class="p">,</span> <span class="n">TradeLogEntry</span>
<span class="kn">from</span> <span class="nn">.util</span> <span class="kn">import</span> <span class="n">UNSET_DOUBLE</span><span class="p">,</span> <span class="n">UNSET_INTEGER</span><span class="p">,</span> <span class="n">dataclassNonDefaults</span>


<div class="viewcode-block" id="Order"><a class="viewcode-back" href="../../api.html#ib_insync.order.Order">[docs]</a><span class="nd">@dataclass</span>
<span class="k">class</span> <span class="nc">Order</span><span class="p">:</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Order for trading contracts.</span>

<span class="sd">    https://interactivebrokers.github.io/tws-api/available_orders.html</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="n">orderId</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">clientId</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">permId</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">action</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">totalQuantity</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">0.0</span>
    <span class="n">orderType</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">lmtPrice</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="n">UNSET_DOUBLE</span>
    <span class="n">auxPrice</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="n">UNSET_DOUBLE</span>
    <span class="n">tif</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">activeStartTime</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">activeStopTime</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">ocaGroup</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">ocaType</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">orderRef</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">transmit</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span>
    <span class="n">parentId</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">blockOrder</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="n">sweepToFill</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="n">displaySize</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">triggerMethod</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">outsideRth</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="n">hidden</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="n">goodAfterTime</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">goodTillDate</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">rule80A</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">allOrNone</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="n">minQty</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="n">UNSET_INTEGER</span>
    <span class="n">percentOffset</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="n">UNSET_DOUBLE</span>
    <span class="n">overridePercentageConstraints</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="n">trailStopPrice</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="n">UNSET_DOUBLE</span>
    <span class="n">trailingPercent</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="n">UNSET_DOUBLE</span>
    <span class="n">faGroup</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">faProfile</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">faMethod</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">faPercentage</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">designatedLocation</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">openClose</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;O&quot;</span>
    <span class="n">origin</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">shortSaleSlot</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">exemptCode</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span>
    <span class="n">discretionaryAmt</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">0.0</span>
    <span class="n">eTradeOnly</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="n">firmQuoteOnly</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="n">nbboPriceCap</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="n">UNSET_DOUBLE</span>
    <span class="n">optOutSmartRouting</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="n">auctionStrategy</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">startingPrice</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="n">UNSET_DOUBLE</span>
    <span class="n">stockRefPrice</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="n">UNSET_DOUBLE</span>
    <span class="n">delta</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="n">UNSET_DOUBLE</span>
    <span class="n">stockRangeLower</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="n">UNSET_DOUBLE</span>
    <span class="n">stockRangeUpper</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="n">UNSET_DOUBLE</span>
    <span class="n">randomizePrice</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="n">randomizeSize</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="n">volatility</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="n">UNSET_DOUBLE</span>
    <span class="n">volatilityType</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="n">UNSET_INTEGER</span>
    <span class="n">deltaNeutralOrderType</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">deltaNeutralAuxPrice</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="n">UNSET_DOUBLE</span>
    <span class="n">deltaNeutralConId</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">deltaNeutralSettlingFirm</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">deltaNeutralClearingAccount</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">deltaNeutralClearingIntent</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">deltaNeutralOpenClose</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">deltaNeutralShortSale</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="n">deltaNeutralShortSaleSlot</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">deltaNeutralDesignatedLocation</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">continuousUpdate</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="n">referencePriceType</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="n">UNSET_INTEGER</span>
    <span class="n">basisPoints</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="n">UNSET_DOUBLE</span>
    <span class="n">basisPointsType</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="n">UNSET_INTEGER</span>
    <span class="n">scaleInitLevelSize</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="n">UNSET_INTEGER</span>
    <span class="n">scaleSubsLevelSize</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="n">UNSET_INTEGER</span>
    <span class="n">scalePriceIncrement</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="n">UNSET_DOUBLE</span>
    <span class="n">scalePriceAdjustValue</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="n">UNSET_DOUBLE</span>
    <span class="n">scalePriceAdjustInterval</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="n">UNSET_INTEGER</span>
    <span class="n">scaleProfitOffset</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="n">UNSET_DOUBLE</span>
    <span class="n">scaleAutoReset</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="n">scaleInitPosition</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="n">UNSET_INTEGER</span>
    <span class="n">scaleInitFillQty</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="n">UNSET_INTEGER</span>
    <span class="n">scaleRandomPercent</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="n">scaleTable</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">hedgeType</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">hedgeParam</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">account</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">settlingFirm</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">clearingAccount</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">clearingIntent</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">algoStrategy</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">algoParams</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="n">TagValue</span><span class="p">]</span> <span class="o">=</span> <span class="n">field</span><span class="p">(</span><span class="n">default_factory</span><span class="o">=</span><span class="nb">list</span><span class="p">)</span>
    <span class="n">smartComboRoutingParams</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="n">TagValue</span><span class="p">]</span> <span class="o">=</span> <span class="n">field</span><span class="p">(</span><span class="n">default_factory</span><span class="o">=</span><span class="nb">list</span><span class="p">)</span>
    <span class="n">algoId</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">whatIf</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="n">notHeld</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="n">solicited</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="n">modelCode</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">orderComboLegs</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="s1">&#39;OrderComboLeg&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">field</span><span class="p">(</span><span class="n">default_factory</span><span class="o">=</span><span class="nb">list</span><span class="p">)</span>
    <span class="n">orderMiscOptions</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="n">TagValue</span><span class="p">]</span> <span class="o">=</span> <span class="n">field</span><span class="p">(</span><span class="n">default_factory</span><span class="o">=</span><span class="nb">list</span><span class="p">)</span>
    <span class="n">referenceContractId</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">peggedChangeAmount</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">0.0</span>
    <span class="n">isPeggedChangeAmountDecrease</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="n">referenceChangeAmount</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">0.0</span>
    <span class="n">referenceExchangeId</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">adjustedOrderType</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">triggerPrice</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="n">UNSET_DOUBLE</span>
    <span class="n">adjustedStopPrice</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="n">UNSET_DOUBLE</span>
    <span class="n">adjustedStopLimitPrice</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="n">UNSET_DOUBLE</span>
    <span class="n">adjustedTrailingAmount</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="n">UNSET_DOUBLE</span>
    <span class="n">adjustableTrailingUnit</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">lmtPriceOffset</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="n">UNSET_DOUBLE</span>
    <span class="n">conditions</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="s1">&#39;OrderCondition&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">field</span><span class="p">(</span><span class="n">default_factory</span><span class="o">=</span><span class="nb">list</span><span class="p">)</span>
    <span class="n">conditionsCancelOrder</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="n">conditionsIgnoreRth</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="n">extOperator</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">softDollarTier</span><span class="p">:</span> <span class="n">SoftDollarTier</span> <span class="o">=</span> <span class="n">field</span><span class="p">(</span><span class="n">default_factory</span><span class="o">=</span><span class="n">SoftDollarTier</span><span class="p">)</span>
    <span class="n">cashQty</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="n">UNSET_DOUBLE</span>
    <span class="n">mifid2DecisionMaker</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">mifid2DecisionAlgo</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">mifid2ExecutionTrader</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">mifid2ExecutionAlgo</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">dontUseAutoPriceForHedge</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="n">isOmsContainer</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="n">discretionaryUpToLimitPrice</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="n">autoCancelDate</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">filledQuantity</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="n">UNSET_DOUBLE</span>
    <span class="n">refFuturesConId</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">autoCancelParent</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="n">shareholder</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">imbalanceOnly</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="n">routeMarketableToBbo</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="n">parentPermId</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">usePriceMgmtAlgo</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="n">duration</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="n">UNSET_INTEGER</span>
    <span class="n">postToAts</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="n">UNSET_INTEGER</span>

    <span class="k">def</span> <span class="fm">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">attrs</span> <span class="o">=</span> <span class="n">dataclassNonDefaults</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span> <span class="ow">is</span> <span class="ow">not</span> <span class="n">Order</span><span class="p">:</span>
            <span class="n">attrs</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s1">&#39;orderType&#39;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">softDollarTier</span><span class="p">:</span>
            <span class="n">attrs</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s1">&#39;softDollarTier&#39;</span><span class="p">)</span>
        <span class="n">clsName</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__qualname__</span>
        <span class="n">kwargs</span> <span class="o">=</span> <span class="s1">&#39;, &#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span>
            <span class="sa">f</span><span class="s1">&#39;</span><span class="si">{</span><span class="n">k</span><span class="si">}</span><span class="s1">=</span><span class="si">{</span><span class="n">v</span><span class="si">!r}</span><span class="s1">&#39;</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">attrs</span><span class="o">.</span><span class="n">items</span><span class="p">())</span>
        <span class="k">return</span> <span class="sa">f</span><span class="s1">&#39;</span><span class="si">{</span><span class="n">clsName</span><span class="si">}</span><span class="s1">(</span><span class="si">{</span><span class="n">kwargs</span><span class="si">}</span><span class="s1">)&#39;</span>

    <span class="fm">__str__</span> <span class="o">=</span> <span class="fm">__repr__</span>

    <span class="k">def</span> <span class="fm">__eq__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span> <span class="ow">is</span> <span class="n">other</span>

    <span class="k">def</span> <span class="fm">__hash__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="nb">id</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span></div>


<div class="viewcode-block" id="LimitOrder"><a class="viewcode-back" href="../../api.html#ib_insync.order.LimitOrder">[docs]</a><span class="k">class</span> <span class="nc">LimitOrder</span><span class="p">(</span><span class="n">Order</span><span class="p">):</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">action</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">totalQuantity</span><span class="p">:</span> <span class="nb">float</span><span class="p">,</span> <span class="n">lmtPrice</span><span class="p">:</span> <span class="nb">float</span><span class="p">,</span>
                 <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="n">Order</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span>
            <span class="bp">self</span><span class="p">,</span> <span class="n">orderType</span><span class="o">=</span><span class="s1">&#39;LMT&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="n">action</span><span class="p">,</span>
            <span class="n">totalQuantity</span><span class="o">=</span><span class="n">totalQuantity</span><span class="p">,</span> <span class="n">lmtPrice</span><span class="o">=</span><span class="n">lmtPrice</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span></div>


<div class="viewcode-block" id="MarketOrder"><a class="viewcode-back" href="../../api.html#ib_insync.order.MarketOrder">[docs]</a><span class="k">class</span> <span class="nc">MarketOrder</span><span class="p">(</span><span class="n">Order</span><span class="p">):</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">action</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">totalQuantity</span><span class="p">:</span> <span class="nb">float</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="n">Order</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span>
            <span class="bp">self</span><span class="p">,</span> <span class="n">orderType</span><span class="o">=</span><span class="s1">&#39;MKT&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="n">action</span><span class="p">,</span>
            <span class="n">totalQuantity</span><span class="o">=</span><span class="n">totalQuantity</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span></div>


<div class="viewcode-block" id="StopOrder"><a class="viewcode-back" href="../../api.html#ib_insync.order.StopOrder">[docs]</a><span class="k">class</span> <span class="nc">StopOrder</span><span class="p">(</span><span class="n">Order</span><span class="p">):</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">action</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">totalQuantity</span><span class="p">:</span> <span class="nb">float</span><span class="p">,</span> <span class="n">stopPrice</span><span class="p">:</span> <span class="nb">float</span><span class="p">,</span>
                 <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="n">Order</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span>
            <span class="bp">self</span><span class="p">,</span> <span class="n">orderType</span><span class="o">=</span><span class="s1">&#39;STP&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="n">action</span><span class="p">,</span>
            <span class="n">totalQuantity</span><span class="o">=</span><span class="n">totalQuantity</span><span class="p">,</span> <span class="n">auxPrice</span><span class="o">=</span><span class="n">stopPrice</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span></div>


<div class="viewcode-block" id="StopLimitOrder"><a class="viewcode-back" href="../../api.html#ib_insync.order.StopLimitOrder">[docs]</a><span class="k">class</span> <span class="nc">StopLimitOrder</span><span class="p">(</span><span class="n">Order</span><span class="p">):</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">action</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">totalQuantity</span><span class="p">:</span> <span class="nb">float</span><span class="p">,</span> <span class="n">lmtPrice</span><span class="p">:</span> <span class="nb">float</span><span class="p">,</span>
                 <span class="n">stopPrice</span><span class="p">:</span> <span class="nb">float</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="n">Order</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span>
            <span class="bp">self</span><span class="p">,</span> <span class="n">orderType</span><span class="o">=</span><span class="s1">&#39;STP LMT&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="n">action</span><span class="p">,</span>
            <span class="n">totalQuantity</span><span class="o">=</span><span class="n">totalQuantity</span><span class="p">,</span> <span class="n">lmtPrice</span><span class="o">=</span><span class="n">lmtPrice</span><span class="p">,</span>
            <span class="n">auxPrice</span><span class="o">=</span><span class="n">stopPrice</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span></div>


<div class="viewcode-block" id="OrderStatus"><a class="viewcode-back" href="../../api.html#ib_insync.order.OrderStatus">[docs]</a><span class="nd">@dataclass</span>
<span class="k">class</span> <span class="nc">OrderStatus</span><span class="p">:</span>
    <span class="n">orderId</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">status</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">filled</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">0.0</span>
    <span class="n">remaining</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">0.0</span>
    <span class="n">avgFillPrice</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">0.0</span>
    <span class="n">permId</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">parentId</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">lastFillPrice</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">0.0</span>
    <span class="n">clientId</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">whyHeld</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">mktCapPrice</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">0.0</span>

    <span class="n">PendingSubmit</span><span class="p">:</span> <span class="n">ClassVar</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;PendingSubmit&#39;</span>
    <span class="n">PendingCancel</span><span class="p">:</span> <span class="n">ClassVar</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;PendingCancel&#39;</span>
    <span class="n">PreSubmitted</span><span class="p">:</span> <span class="n">ClassVar</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;PreSubmitted&#39;</span>
    <span class="n">Submitted</span><span class="p">:</span> <span class="n">ClassVar</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;Submitted&#39;</span>
    <span class="n">ApiPending</span><span class="p">:</span> <span class="n">ClassVar</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;ApiPending&#39;</span>
    <span class="n">ApiCancelled</span><span class="p">:</span> <span class="n">ClassVar</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;ApiCancelled&#39;</span>
    <span class="n">Cancelled</span><span class="p">:</span> <span class="n">ClassVar</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;Cancelled&#39;</span>
    <span class="n">Filled</span><span class="p">:</span> <span class="n">ClassVar</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;Filled&#39;</span>
    <span class="n">Inactive</span><span class="p">:</span> <span class="n">ClassVar</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;Inactive&#39;</span>

    <span class="n">DoneStates</span><span class="p">:</span> <span class="n">ClassVar</span><span class="p">[</span><span class="n">Set</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;Filled&#39;</span><span class="p">,</span> <span class="s1">&#39;Cancelled&#39;</span><span class="p">,</span> <span class="s1">&#39;ApiCancelled&#39;</span><span class="p">}</span>
    <span class="n">ActiveStates</span><span class="p">:</span> <span class="n">ClassVar</span><span class="p">[</span><span class="n">Set</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="p">{</span>
        <span class="s1">&#39;PendingSubmit&#39;</span><span class="p">,</span> <span class="s1">&#39;ApiPending&#39;</span><span class="p">,</span> <span class="s1">&#39;PreSubmitted&#39;</span><span class="p">,</span> <span class="s1">&#39;Submitted&#39;</span><span class="p">}</span></div>


<div class="viewcode-block" id="OrderState"><a class="viewcode-back" href="../../api.html#ib_insync.order.OrderState">[docs]</a><span class="nd">@dataclass</span>
<span class="k">class</span> <span class="nc">OrderState</span><span class="p">:</span>
    <span class="n">status</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">initMarginBefore</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">maintMarginBefore</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">equityWithLoanBefore</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">initMarginChange</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">maintMarginChange</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">equityWithLoanChange</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">initMarginAfter</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">maintMarginAfter</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">equityWithLoanAfter</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">commission</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="n">UNSET_DOUBLE</span>
    <span class="n">minCommission</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="n">UNSET_DOUBLE</span>
    <span class="n">maxCommission</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="n">UNSET_DOUBLE</span>
    <span class="n">commissionCurrency</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">warningText</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">completedTime</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">completedStatus</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span></div>


<div class="viewcode-block" id="OrderComboLeg"><a class="viewcode-back" href="../../api.html#ib_insync.order.OrderComboLeg">[docs]</a><span class="nd">@dataclass</span>
<span class="k">class</span> <span class="nc">OrderComboLeg</span><span class="p">:</span>
    <span class="n">price</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="n">UNSET_DOUBLE</span></div>


<div class="viewcode-block" id="Trade"><a class="viewcode-back" href="../../api.html#ib_insync.order.Trade">[docs]</a><span class="nd">@dataclass</span>
<span class="k">class</span> <span class="nc">Trade</span><span class="p">:</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Trade keeps track of an order, its status and all its fills.</span>

<span class="sd">    Events:</span>
<span class="sd">        * ``statusEvent`` (trade: :class:`.Trade`)</span>
<span class="sd">        * ``modifyEvent`` (trade: :class:`.Trade`)</span>
<span class="sd">        * ``fillEvent`` (trade: :class:`.Trade`, fill: :class:`.Fill`)</span>
<span class="sd">        * ``commissionReportEvent`` (trade: :class:`.Trade`,</span>
<span class="sd">          fill: :class:`.Fill`, commissionReport: :class:`.CommissionReport`)</span>
<span class="sd">        * ``filledEvent`` (trade: :class:`.Trade`)</span>
<span class="sd">        * ``cancelEvent`` (trade: :class:`.Trade`)</span>
<span class="sd">        * ``cancelledEvent`` (trade: :class:`.Trade`)</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="n">events</span><span class="p">:</span> <span class="n">ClassVar</span> <span class="o">=</span> <span class="p">(</span>
        <span class="s1">&#39;statusEvent&#39;</span><span class="p">,</span> <span class="s1">&#39;modifyEvent&#39;</span><span class="p">,</span> <span class="s1">&#39;fillEvent&#39;</span><span class="p">,</span>
        <span class="s1">&#39;commissionReportEvent&#39;</span><span class="p">,</span> <span class="s1">&#39;filledEvent&#39;</span><span class="p">,</span>
        <span class="s1">&#39;cancelEvent&#39;</span><span class="p">,</span> <span class="s1">&#39;cancelledEvent&#39;</span><span class="p">)</span>

    <span class="n">contract</span><span class="p">:</span> <span class="n">Contract</span> <span class="o">=</span> <span class="n">field</span><span class="p">(</span><span class="n">default_factory</span><span class="o">=</span><span class="n">Contract</span><span class="p">)</span>
    <span class="n">order</span><span class="p">:</span> <span class="n">Order</span> <span class="o">=</span> <span class="n">field</span><span class="p">(</span><span class="n">default_factory</span><span class="o">=</span><span class="n">Order</span><span class="p">)</span>
    <span class="n">orderStatus</span><span class="p">:</span> <span class="s1">&#39;OrderStatus&#39;</span> <span class="o">=</span> <span class="n">field</span><span class="p">(</span><span class="n">default_factory</span><span class="o">=</span><span class="n">OrderStatus</span><span class="p">)</span>
    <span class="n">fills</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="n">Fill</span><span class="p">]</span> <span class="o">=</span> <span class="n">field</span><span class="p">(</span><span class="n">default_factory</span><span class="o">=</span><span class="nb">list</span><span class="p">)</span>
    <span class="n">log</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="n">TradeLogEntry</span><span class="p">]</span> <span class="o">=</span> <span class="n">field</span><span class="p">(</span><span class="n">default_factory</span><span class="o">=</span><span class="nb">list</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">__post_init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">statusEvent</span> <span class="o">=</span> <span class="n">Event</span><span class="p">(</span><span class="s1">&#39;statusEvent&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">modifyEvent</span> <span class="o">=</span> <span class="n">Event</span><span class="p">(</span><span class="s1">&#39;modifyEvent&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">fillEvent</span> <span class="o">=</span> <span class="n">Event</span><span class="p">(</span><span class="s1">&#39;fillEvent&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">commissionReportEvent</span> <span class="o">=</span> <span class="n">Event</span><span class="p">(</span><span class="s1">&#39;commissionReportEvent&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">filledEvent</span> <span class="o">=</span> <span class="n">Event</span><span class="p">(</span><span class="s1">&#39;filledEvent&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">cancelEvent</span> <span class="o">=</span> <span class="n">Event</span><span class="p">(</span><span class="s1">&#39;cancelEvent&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">cancelledEvent</span> <span class="o">=</span> <span class="n">Event</span><span class="p">(</span><span class="s1">&#39;cancelledEvent&#39;</span><span class="p">)</span>

<div class="viewcode-block" id="Trade.isActive"><a class="viewcode-back" href="../../api.html#ib_insync.order.Trade.isActive">[docs]</a>    <span class="k">def</span> <span class="nf">isActive</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;True if eligible for execution, false otherwise.&quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">orderStatus</span><span class="o">.</span><span class="n">status</span> <span class="ow">in</span> <span class="n">OrderStatus</span><span class="o">.</span><span class="n">ActiveStates</span></div>

<div class="viewcode-block" id="Trade.isDone"><a class="viewcode-back" href="../../api.html#ib_insync.order.Trade.isDone">[docs]</a>    <span class="k">def</span> <span class="nf">isDone</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;True if completely filled or cancelled, false otherwise.&quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">orderStatus</span><span class="o">.</span><span class="n">status</span> <span class="ow">in</span> <span class="n">OrderStatus</span><span class="o">.</span><span class="n">DoneStates</span></div>

<div class="viewcode-block" id="Trade.filled"><a class="viewcode-back" href="../../api.html#ib_insync.order.Trade.filled">[docs]</a>    <span class="k">def</span> <span class="nf">filled</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Number of shares filled.&quot;&quot;&quot;</span>
        <span class="n">fills</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fills</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">contract</span><span class="o">.</span><span class="n">secType</span> <span class="o">==</span> <span class="s1">&#39;BAG&#39;</span><span class="p">:</span>
            <span class="c1"># don&#39;t count fills for the leg contracts</span>
            <span class="n">fills</span> <span class="o">=</span> <span class="p">[</span><span class="n">f</span> <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">fills</span> <span class="k">if</span> <span class="n">f</span><span class="o">.</span><span class="n">contract</span><span class="o">.</span><span class="n">secType</span> <span class="o">==</span> <span class="s1">&#39;BAG&#39;</span><span class="p">]</span>
        <span class="k">return</span> <span class="nb">sum</span><span class="p">(</span><span class="n">f</span><span class="o">.</span><span class="n">execution</span><span class="o">.</span><span class="n">shares</span> <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">fills</span><span class="p">)</span></div>

<div class="viewcode-block" id="Trade.remaining"><a class="viewcode-back" href="../../api.html#ib_insync.order.Trade.remaining">[docs]</a>    <span class="k">def</span> <span class="nf">remaining</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Number of shares remaining to be filled.&quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">order</span><span class="o">.</span><span class="n">totalQuantity</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">filled</span><span class="p">()</span></div></div>


<div class="viewcode-block" id="BracketOrder"><a class="viewcode-back" href="../../api.html#ib_insync.order.BracketOrder">[docs]</a><span class="k">class</span> <span class="nc">BracketOrder</span><span class="p">(</span><span class="n">NamedTuple</span><span class="p">):</span>
    <span class="n">parent</span><span class="p">:</span> <span class="n">Order</span>
    <span class="n">takeProfit</span><span class="p">:</span> <span class="n">Order</span>
    <span class="n">stopLoss</span><span class="p">:</span> <span class="n">Order</span></div>


<div class="viewcode-block" id="OrderCondition"><a class="viewcode-back" href="../../api.html#ib_insync.order.OrderCondition">[docs]</a><span class="nd">@dataclass</span>
<span class="k">class</span> <span class="nc">OrderCondition</span><span class="p">:</span>

<div class="viewcode-block" id="OrderCondition.createClass"><a class="viewcode-back" href="../../api.html#ib_insync.order.OrderCondition.createClass">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">createClass</span><span class="p">(</span><span class="n">condType</span><span class="p">):</span>
        <span class="n">d</span> <span class="o">=</span> <span class="p">{</span>
            <span class="mi">1</span><span class="p">:</span> <span class="n">PriceCondition</span><span class="p">,</span>
            <span class="mi">3</span><span class="p">:</span> <span class="n">TimeCondition</span><span class="p">,</span>
            <span class="mi">4</span><span class="p">:</span> <span class="n">MarginCondition</span><span class="p">,</span>
            <span class="mi">5</span><span class="p">:</span> <span class="n">ExecutionCondition</span><span class="p">,</span>
            <span class="mi">6</span><span class="p">:</span> <span class="n">VolumeCondition</span><span class="p">,</span>
            <span class="mi">7</span><span class="p">:</span> <span class="n">PercentChangeCondition</span><span class="p">}</span>
        <span class="k">return</span> <span class="n">d</span><span class="p">[</span><span class="n">condType</span><span class="p">]</span></div>

<div class="viewcode-block" id="OrderCondition.And"><a class="viewcode-back" href="../../api.html#ib_insync.order.OrderCondition.And">[docs]</a>    <span class="k">def</span> <span class="nf">And</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">conjunction</span> <span class="o">=</span> <span class="s1">&#39;a&#39;</span>
        <span class="k">return</span> <span class="bp">self</span></div>

<div class="viewcode-block" id="OrderCondition.Or"><a class="viewcode-back" href="../../api.html#ib_insync.order.OrderCondition.Or">[docs]</a>    <span class="k">def</span> <span class="nf">Or</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">conjunction</span> <span class="o">=</span> <span class="s1">&#39;o&#39;</span>
        <span class="k">return</span> <span class="bp">self</span></div></div>


<div class="viewcode-block" id="PriceCondition"><a class="viewcode-back" href="../../api.html#ib_insync.order.PriceCondition">[docs]</a><span class="nd">@dataclass</span>
<span class="k">class</span> <span class="nc">PriceCondition</span><span class="p">(</span><span class="n">OrderCondition</span><span class="p">):</span>
    <span class="n">condType</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">1</span>
    <span class="n">conjunction</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;a&#39;</span>
    <span class="n">isMore</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span>
    <span class="n">price</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">0.0</span>
    <span class="n">conId</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">exch</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">triggerMethod</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span></div>


<div class="viewcode-block" id="TimeCondition"><a class="viewcode-back" href="../../api.html#ib_insync.order.TimeCondition">[docs]</a><span class="nd">@dataclass</span>
<span class="k">class</span> <span class="nc">TimeCondition</span><span class="p">(</span><span class="n">OrderCondition</span><span class="p">):</span>
    <span class="n">condType</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">3</span>
    <span class="n">conjunction</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;a&#39;</span>
    <span class="n">isMore</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span>
    <span class="n">time</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span></div>


<div class="viewcode-block" id="MarginCondition"><a class="viewcode-back" href="../../api.html#ib_insync.order.MarginCondition">[docs]</a><span class="nd">@dataclass</span>
<span class="k">class</span> <span class="nc">MarginCondition</span><span class="p">(</span><span class="n">OrderCondition</span><span class="p">):</span>
    <span class="n">condType</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">4</span>
    <span class="n">conjunction</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;a&#39;</span>
    <span class="n">isMore</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span>
    <span class="n">percent</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span></div>


<div class="viewcode-block" id="ExecutionCondition"><a class="viewcode-back" href="../../api.html#ib_insync.order.ExecutionCondition">[docs]</a><span class="nd">@dataclass</span>
<span class="k">class</span> <span class="nc">ExecutionCondition</span><span class="p">(</span><span class="n">OrderCondition</span><span class="p">):</span>
    <span class="n">condType</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">5</span>
    <span class="n">conjunction</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;a&#39;</span>
    <span class="n">secType</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">exch</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">symbol</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span></div>


<div class="viewcode-block" id="VolumeCondition"><a class="viewcode-back" href="../../api.html#ib_insync.order.VolumeCondition">[docs]</a><span class="nd">@dataclass</span>
<span class="k">class</span> <span class="nc">VolumeCondition</span><span class="p">(</span><span class="n">OrderCondition</span><span class="p">):</span>
    <span class="n">condType</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">6</span>
    <span class="n">conjunction</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;a&#39;</span>
    <span class="n">isMore</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span>
    <span class="n">volume</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">conId</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">exch</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span></div>


<div class="viewcode-block" id="PercentChangeCondition"><a class="viewcode-back" href="../../api.html#ib_insync.order.PercentChangeCondition">[docs]</a><span class="nd">@dataclass</span>
<span class="k">class</span> <span class="nc">PercentChangeCondition</span><span class="p">(</span><span class="n">OrderCondition</span><span class="p">):</span>
    <span class="n">condType</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">7</span>
    <span class="n">conjunction</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;a&#39;</span>
    <span class="n">isMore</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span>
    <span class="n">changePercent</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">0.0</span>
    <span class="n">conId</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">exch</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span></div>
</pre></div>

           </div>
          </div>
          <footer>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2021, Ewald de Wit.</p>
  </div>

  Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
    <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
    provided by <a href="https://readthedocs.org">Read the Docs</a>.
   

</footer>
        </div>
      </div>
    </section>
  </div>
  <script>
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script> 

</body>
</html>